package com.cs.paoyer.common.util;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
import javax.servlet.http.HttpServletRequest;

public class ManageSession 
{
  
  public ManageSession()
  {
  }


public static void resetSessionAdjust(HttpServletRequest request, Collection noRemovableColl ) {

    Enumeration enum1 = request.getSession().getAttributeNames();
    
     while (enum1.hasMoreElements()) {
        String item = (String)enum1.nextElement();
        Iterator noRemovableIt = noRemovableColl.iterator();
        boolean flagRemove = true;
        
       while(noRemovableIt.hasNext()){  
        String atrNoRemovable = (String)noRemovableIt.next();
     
            if ( item.equals(atrNoRemovable) ){
              flagRemove = false;
              break;
              }
        }
        
         if(flagRemove){
           request.getSession().removeAttribute(item);
          }
       }
  }


public static void resetSessionAdjust(HttpServletRequest request, String noRemovableAtr ) {

    Enumeration enum1 = request.getSession().getAttributeNames();
    
     while (enum1.hasMoreElements()) {
        String item = (String)enum1.nextElement();
           
        if ( !item.equals(noRemovableAtr) ){
             request.getSession().removeAttribute(item);
            }
         }
      }
}







